/**
 * A weld joint essentially glues two bodies together. A weld joint may
 * distort somewhat because the island constraint solver is approximate.
**/
public class b2WeldJoint extends b2Joint {

	public b2WeldJoint(int addr) {
		super(addr);
	}

	@Override
	public void release() {
		if ( address != 0 ) {
			super.release();
		}
	}

	/**remember to call release() on the returned object*/
	public b2Vec2 GetAnchorA() {
		return new b2Vec2(jniGetAnchorA(address));
	}

	/**remember to call release() on the returned object*/
	public b2Vec2 GetAnchorB() {
		return new b2Vec2(jniGetAnchorB(address));
	}

	/// Get the reaction force given the inverse time step.
	/// Unit is N.
	public b2Vec2 GetReactionForce(float inv_dt) {
		return new b2Vec2(jniGetReactionForce(address));
	}

	/// Get the reaction torque due to the joint limit given the inverse time step.
	/// Unit is N*m.
	public float GetReactionTorque(float inv_dt) {
		return jniGetReactionTorque(address, inv_dt);
	}

	/// The local anchor point relative to bodyA's origin.
	public b2Vec2 GetLocalAnchorA() {
		return new b2Vec2(jniGetLocalAnchorA(address));
	}

	/// The local anchor point relative to bodyB's origin.
	public b2Vec2 GetLocalAnchorB() {
		return new b2Vec2(jniGetLocalAnchorB(address));
	}

	/// Get the reference angle.
	public float GetReferenceAngle() {
		return jniGetReferenceAngle(address);
	}

	/// Set/get frequency in Hz.
	public void SetFrequency(float hz) {
		jniSetFrequency(address, hz);
	}

	public float GetFrequency() {
		return jniGetFrequency(address);
	}

	/// Set/get damping ratio.
	public void SetDampingRatio(float ratio) {
		jniSetDampingRatio(address, ratio);
	}

	public float GetDampingRatio() {
		return jniGetDampingRatio(address);
	}

	/// Dump to b2Log.
	public void Dump() {
		throw new UnsupportedOperationException();
	}

	private static native int jniGetAnchorA(int me);
	private static native int jniGetAnchorB(int me);
	private static native float jniGetReactionTorque(int me, float inv_dt);
	private static native int jniGetReactionForce(int me);
	private static native int jniGetLocalAnchorA(int me);
	private static native int jniGetLocalAnchorB(int me);
	private static native float jniGetReferenceAngle(int me);
	private static native float jniGetFrequency(int me);
	private static native void jniSetFrequency(int me, float hz);
	private static native float jniGetSpringDampingRatio(int me);
	private static native void jniSetSpringDampingRatio(int me, float ratio);
	private static native void jniSetDampingRatio(int me, float ratio);
	private static native float jniGetDampingRatio(int me);
}
